﻿@page "/WebSite"
@attribute [StreamRendering]
@inject NavigationManager NavigationManager;

<PageTitle>站点列表</PageTitle>

<div class="bg-white p-5">
    <Button class="layui-btn layui-btn-sm">Nginx</Button>
    <Button Type="@ButtonType.Primary" class="layui-btn layui-btn-primary layui-border-green layui-btn-radius layui-btn-sm">已启动</Button>
    <span class="layui-btn layui-btn-primary layui-border-blue layui-btn-sm">v1.4.2.6</span>
    <Button Type="@ButtonType.Primary" Danger class="layui-btn layui-btn-danger layui-btn-sm">停止</Button>
    <Button Type="@ButtonType.Primary" Danger class="layui-btn layui-btn-danger layui-btn-sm">重启</Button>
    <Button Type="@ButtonType.Primary" Danger class="layui-btn layui-btn-danger layui-btn-sm">重载</Button>
    <Button Type="@ButtonType.Primary" class="layui-btn layui-bg-blue layui-btn-sm">设置</Button>
</div>

<div class="bg-white p-4 flex flex-row justify-between mt-4">
    <div>
        <Button Type="@ButtonType.Primary" class="layui-btn" OnClick="GoAddPage">添加网站</Button>
    </div>
    <div class="layui-form">
        <div class="layui-input-wrap">
            <Search Placeholder="搜索…" />
        </div>
    </div>
</div>

<div class="mt-5 bg-white p-5">
    <Table DataSource="_tableLists" Bordered="true">
        <PropertyColumn Property="c => c.Id" Title="标题">
            @context.Title
        </PropertyColumn>
        <PropertyColumn Property="c => c.Type" Title="类型">
            <Tag Color="@PresetColor.Blue.ToString()">@context.Type</Tag>
        </PropertyColumn>
        <PropertyColumn Property="c => c.Status" Title="状态">
            @if (context.Status == 1)
            {
                <Tag Color="@PresetColor.Green.ToString()">运行中</Tag>
            }
            else
            {
                <Tag Color="@PresetColor.Red.ToString()">停止</Tag>
            }
        </PropertyColumn>
        <PropertyColumn Property="c => c.Backup" Title="备份">
            @if (context.Backup > 0)
            {
                <span>已备份<Badge Count="8"></Badge></span>
            }
            else
            {
                <span>未备份</span>
            }
        </PropertyColumn>
        <PropertyColumn Property="c=>c.Root" Title="目录"></PropertyColumn>
        <PropertyColumn Property="c=>c.Ssl" Title="SSL"></PropertyColumn>
    </Table>
</div>


@code {
    record  TableList
    {
        public long Id { get; set; }
        public string Title { get; set; }
        public string Type { get; set; }
        public int Status { get; set; }
        public int Backup { get; set; }
        public string Root { get; set; }
        public string Ssl { get; set; }
    }

    List<TableList> _tableLists =
    [
        new TableList(){ Id = 1, Title = "www.baidu.com", Type = "PHP", Status = 1, Backup = 3, Root = "/www/wwwroot/www.baidu.com", Ssl = "http"},
        new TableList(){ Id = 2, Title = "www.google.com", Type = "代理", Status = 2, Backup = 0, Root = "/www/wwwroot/www.google.com", Ssl = "https"},
        new TableList(){ Id = 3, Title = "www.bing.com", Type = "NodeJS", Status = 2, Backup = 0, Root = "/www/wwwroot/www.bing.com", Ssl = "https"},
        new TableList(){ Id = 4, Title = "www.yahoo.com", Type = "静态", Status = 1, Backup = 23, Root = "/www/wwwroot/www.yahoo.com", Ssl = "http"},
    ];

    void GoAddPage()
    {
        NavigationManager.NavigateTo("/website/add");
    }
}